package com.cy.lib.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.GridView;

/**
 * Created by CY on 2015/8/28.
 *
 * @title 全屏高GridView
 */
public class MatchGridView extends GridView {

    public MatchGridView(Context context) {
        super(context);
    }

    public MatchGridView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MatchGridView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }


    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

//        int rows = getAdapter().getCount() % getNumColumns() == 0 ? getAdapter().getCount() / getNumColumns() : getAdapter().getCount() / getNumColumns() + 1;

//        告诉父控件所需要的宽高
//        setMeasuredDimension();

        int height = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 1, MeasureSpec.AT_MOST);
        super.onMeasure(widthMeasureSpec, height);
    }
}
